//
//  SecondTranslasion.swift
//  elarc01
//
//  Created by elarc on 16/4/15.
//  Copyright © 2016年 elarc. All rights reserved.
//

import Foundation
import TransitionTreasury
import TransitionAnimation

class SecondTranslasionVC:UIViewController,NavgationTransitionable,UITableViewDelegate, UITableViewDataSource{
    var tr_pushTransition: TRNavgationTransitionDelegate?
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initBarManager()
        self.view.backgroundColor = UIColor.whiteColor()
        
        let btn = UIButton(type: .Custom)
        btn.frame = CGRectMake(100, 100, 100, 40)
        btn.titleLabel?.text = "popTo"
        btn.backgroundColor = UIColor.yellowColor()
        self.view.addSubview(btn)
        btn.addTarget(self, action: #selector(SecondTranslasionVC.popTo), forControlEvents: UIControlEvents.TouchUpInside)
        
        let tableView = TableviewCellZoomAnimation ()
        tableView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight)
        tableView.delegate = self
        tableView.dataSource = self
        self.view.addSubview(tableView)
        
        
    }
    
    //导航栏隐藏2
    func initBarManager() {
        TransparentNavigationBarVC.managerWithController(self)
        TransparentNavigationBarVC.setBarColor(UIColor.blueColor())
        TransparentNavigationBarVC.setTintColor(UIColor.redColor())
        TransparentNavigationBarVC.setStatusBarStyle(UIStatusBarStyle.Default)
        TransparentNavigationBarVC.setZeroAlphaOffset(-64)
        TransparentNavigationBarVC.setFullAlphaOffset(200)
        
        TransparentNavigationBarVC.setFullAlphaTintColor(UIColor.whiteColor())
        TransparentNavigationBarVC.setFullAlphaBarStyle(UIStatusBarStyle.LightContent)
//        TransparentNavigationBarVC.setContinues(false)
        
    }
    //导航栏隐藏2
    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        TransparentNavigationBarVC.reStoreWithZeroStatus()
//        TransparentNavigationBarVC.setReversal(false)
//        TransparentNavigationBarVC.setContinues(true)
    }
    
    func scrollViewDidScroll(scrollView: UIScrollView) {
        TransparentNavigationBarVC.changeAlphaWithCurrentOffset(scrollView.contentOffset.y)
    }
    
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1;
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 8;
    }
    
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return 363.0;
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let cellId = "StoreHouseCell"
        var cell = tableView.dequeueReusableCellWithIdentifier(cellId) as? ElarcScalableTableViewCell
        if cell == nil {
            cell = ElarcScalableTableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: cellId)
        }
        return cell!
    }

    
    func popTo () {
        (self.transitioningDelegate as! UIViewController).dismissViewControllerAnimated(true, completion: nil)
    }
}